package ui;

import java.util.HashSet;
import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite;
import each_class.SongClass;

public class RecentMusicUI extends AbstractUI {

	private Set<SongClass> recentSet = new HashSet<>();
	private MusicView musicView;
	public RecentMusicUI(Composite parent, int style) {
		super(parent, style);
		title.setText("最近播放");
		
		musicView = new MusicView(this, SWT.NONE);
		musicView.setBounds(0, 123, 1210, 513);
		
		TabFolderItem musicItem =  new TabFolderItem(tabFolder, musicView);
		TabFolderItem musicListItem =  new TabFolderItem(tabFolder, null);
		tabFolder.setFont(new Font(getDisplay(), "Microsoft YaHei UI", 18, SWT.NORMAL));
		musicItem.setText("歌曲");
		musicListItem.setText("歌单");
		tabFolder.setCurrentTabFolderItem(musicItem);
		tabFolder.getCurrentTabFolderItem().active();
		tabFolder.layout();
	}
	
	public void initail(Set<SongClass> musicList) {
		musicView.dispose();
		musicView = new MusicView(this, SWT.NONE);
		musicView.setBounds(0, 123, 1210, 513);
		musicView.loadMusic(musicList);
	}

	@Override
	public void active() {
		setVisible(true);
		if (!recentSet.isEmpty()) {
			initail(recentSet);
		}	
	}
	
	public void addRecent(SongClass recent) {
		recentSet.add(recent);
	}
}
